.index = -1,
};
-#define __RETCODE 0
static int __init xen_console_init(void)
{
if (!is_running_on_xen())
- return __RETCODE;
+ goto out;
if (is_initial_xendomain()) {
if (xc_mode == XC_DEFAULT)
xc_mode = XC_SERIAL;
kcons_info.write = kcons_write_dom0;
} else {
+ if (!xen_start_info->console.domU.evtchn)
+ goto out;
if (xc_mode == XC_DEFAULT)
xc_mode = XC_TTY;
kcons_info.write = kcons_write;
break;
default:
- return __RETCODE;
+ goto out;
}
wbuf = alloc_bootmem(wbuf_size);
register_console(&kcons_info);
- return __RETCODE;
+ out:
+ return 0;
}
console_initcall(xen_console_init);
int sz;
/* Emergency console is synchronous, so there's nothing to flush. */
- if (is_initial_xendomain())
+ if (!is_running_on_xen() ||
+ is_initial_xendomain() ||
+ !xen_start_info->console.domU.evtchn)
return;
/* Spin until console data is flushed through to the daemon. */
if (xc_mode == XC_OFF)
return 0;
- xencons_ring_init();
+ if (!is_initial_xendomain()) {
+ rc = xencons_ring_init();
+ if (rc)
+ return rc;
+ }
xencons_driver = alloc_tty_driver((xc_mode == XC_SERIAL) ?
1 : MAX_NR_CONSOLES);
int xencons_ring_init(void)
{
- int err;
+ int irq;
if (xencons_irq)
unbind_from_irqhandler(xencons_irq, NULL);
xencons_irq = 0;
- if (!xen_start_info->console.domU.evtchn)
- return 0;
+ if (!is_running_on_xen() ||
+ is_initial_xendomain() ||
+ !xen_start_info->console.domU.evtchn)
+ return -ENODEV;
- err = bind_evtchn_to_irqhandler(
+ irq = bind_evtchn_to_irqhandler(
xen_start_info->console.domU.evtchn,
handle_input, 0, "xencons", NULL);
- if (err <= 0) {
- printk(KERN_ERR "XEN console request irq failed %i\n", err);
+ if (irq < 0) {
+ printk(KERN_ERR "XEN console request irq failed %i\n", irq);
return err;
}
- xencons_irq = err;
+ xencons_irq = irq;
/* In case we have in-flight data after save/restore... */
notify_daemon();